package com.quasar.hpatient.bean.doctor;

import android.support.annotation.NonNull;
import android.text.TextUtils;

import lib.quasar.context.BaseConstant;
import lib.quasar.util.PinyinUtil;

import static java.lang.Character.UnicodeBlock.CJK_COMPATIBILITY_FORMS;
import static java.lang.Character.UnicodeBlock.CJK_COMPATIBILITY_IDEOGRAPHS;
import static java.lang.Character.UnicodeBlock.CJK_RADICALS_SUPPLEMENT;
import static java.lang.Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS;
import static java.lang.Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A;
import static java.lang.Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_B;

/**
 * description: 我的医生列表
 * created by kalu on 2018/3/28 9:31
 */
public class DoctorBean implements Comparable<DoctorBean> {

    //1：待审核关系
    //2：成功建立医患关系
    //3：已解除关系
    //4：医生特别关注患者
    //10：患者好友关系
    //11：已删除患者好友关系
    //20：医生好友关系
    //21：已删除医生好友关系
    //22：医生已经拒绝患者
    //30：停止随访
    //  ：共享
    //  ：分配
    private int relation_type;
    private long patientid;
    private long doctorid;
    private String operation_datetime = "";
    private String position_name = "";
    private String hospital_name = "";
    private String icon = "";
    private String real_name = "";
    private String dynamic_info = "";
    private String dynamic_begintime = "";
    private String dynamic_endtime = "";

    private int sex;
    private String pname;
    private String hname;
    private String visit_info;

    private String letter = "";

    public int getSex() {
        return sex;
    }

    public void setSex(int sex) {
        this.sex = sex;
    }

    public String getPname() {
        return pname;
    }

    public void setPname(String pname) {
        this.pname = pname;
    }

    public String getHname() {
        return hname;
    }

    public void setHname(String hname) {
        this.hname = hname;
    }

    public String getVisit_info() {
        return visit_info;
    }

    public void setVisit_info(String visit_info) {
        this.visit_info = visit_info;
    }

    public String getCover() {
        // return BaseConstant.API_URL + cover;
        return "http://www.qqzhi.com/uploadpic/2014-09-23/000247589.jpg";
    }

    /****************************************************************************/

    public long getPatientid() {
        return patientid;
    }

    public void setPatientid(long patientid) {
        this.patientid = patientid;
    }

    public long getDoctorid() {
        return doctorid;
    }

    public void setDoctorid(long doctorid) {
        this.doctorid = doctorid;
    }

    public int getRelation_type() {
        return relation_type;
    }

    public void setRelation_type(int relation_type) {
        this.relation_type = relation_type;
    }

    public String getOperation_datetime() {
        return operation_datetime;
    }

    public void setOperation_datetime(String operation_datetime) {
        this.operation_datetime = operation_datetime;
    }

    public String getIcon() {
        return icon;
    }

    public void setIcon(String icon) {
        this.icon = icon;
    }

    public String getReal_name() {
        return real_name;
    }

    public void setReal_name(String real_name) {
        this.real_name = real_name;
    }

    public String getPosition_name() {
        return position_name;
    }

    public void setPosition_name(String position_name) {
        this.position_name = position_name;
    }

    public String getHospital_name() {
        return hospital_name;
    }

    public void setHospital_name(String hospital_name) {
        this.hospital_name = hospital_name;
    }

    public String getDynamic_info() {
        return dynamic_info;
    }

    public void setDynamic_info(String dynamic_info) {
        this.dynamic_info = dynamic_info;
    }

    public String getDynamic_begintime() {
        return dynamic_begintime;
    }

    public void setDynamic_begintime(String dynamic_begintime) {
        this.dynamic_begintime = dynamic_begintime;
    }

    public String getDynamic_endtime() {
        return dynamic_endtime;
    }

    public void setDynamic_endtime(String dynamic_endtime) {
        this.dynamic_endtime = dynamic_endtime;
    }

    /**************************************************************/

    public final String getLetter() {

        if (TextUtils.isEmpty(letter)) {

            if (TextUtils.isEmpty(real_name)) {
                letter = BaseConstant.WELL;
            } else {
                final char begin = real_name.charAt(0);
                final String string = String.valueOf(begin);
                final Character.UnicodeBlock ub = Character.UnicodeBlock.of(begin);
                if (CJK_UNIFIED_IDEOGRAPHS == ub || CJK_COMPATIBILITY_IDEOGRAPHS == ub || CJK_COMPATIBILITY_FORMS == ub ||
                        CJK_RADICALS_SUPPLEMENT == ub || CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A == ub || CJK_UNIFIED_IDEOGRAPHS_EXTENSION_B == ub) {
                    letter = PinyinUtil.ch2py(string).toUpperCase();
                } else {
                    letter = PinyinUtil.isNumber(string) ? BaseConstant.WELL : string;
                }
            }
        }
        return letter;
    }

    public void setLetter(String letter) {
        this.letter = letter;
    }

    @Override
    public int compareTo(@NonNull DoctorBean o) {
        return this.getLetter().compareTo(o.getLetter());
    }

    @Override
    public String toString() {
        return "DoctorBean{" +
                "relation_type=" + relation_type +
                ", patientid=" + patientid +
                ", doctorid=" + doctorid +
                ", operation_datetime='" + operation_datetime + '\'' +
                ", position_name='" + position_name + '\'' +
                ", hospital_name='" + hospital_name + '\'' +
                ", icon='" + icon + '\'' +
                ", real_name='" + real_name + '\'' +
                ", dynamic_info='" + dynamic_info + '\'' +
                ", dynamic_begintime='" + dynamic_begintime + '\'' +
                ", dynamic_endtime='" + dynamic_endtime + '\'' +
                ", sex=" + sex +
                ", pname='" + pname + '\'' +
                ", hname='" + hname + '\'' +
                ", visit_info='" + visit_info + '\'' +
                ", letter='" + letter + '\'' +
                '}';
    }
}
